import { pageState } from '@/redux/c_state'

// 初始数据
const initState = {
  list0: [], // 表格0 数据
  total0: 0, // 表格0 总条数
  pageState0: pageState,
  list1: [], // 表格1 数据
  total1: 0, // 表格1 总条数
  pageState1: pageState,
}
// 更新 数据reducer
export default (state = initState, action: actionType) => {
  const { type, payload } = action
  switch (type) {
    case 'HOME/setupTable0':
      return {
        ...state,
        list0: payload.list || [],
        total0: payload.total || 0,
      }
    case 'HOME/setupPage0':
      return {
        ...state,
        pageState0: {
          ...state.pageState0,
          ...payload,
        },
      }
    case 'HOME/setupTable1':
      return {
        ...state,
        list1: payload.list || [],
        total1: payload.total || 0,
      }
    case 'HOME/setupPage1':
      return {
        ...state,
        pageState1: {
          ...state.pageState1,
          ...payload,
        },
      }
    default:
      return state
  }
}
